#pragma once

#include "errors.h"

#define READER_RESULT_CODE_DONE 0
#define READER_RESULT_CODE_END 1
#define READER_RESULT_CODE_LARGE -1
#define READER_RESULT_CODE_INVALID -2
class ArrayIterator
{
public:
	ArrayIterator() {}
	ArrayIterator( char* bf , long pointer , long size );
	~ArrayIterator() {}
	char operator*();
	void operator++();
	bool operator == (ArrayIterator const& i);
    bool operator != (ArrayIterator const& i);
	ArrayIterator& operator =(const ArrayIterator& other);
private:
	long m_length;
	long m_pointer;
	char* m_pBuffer;
};

template< class Iter>
class BufferIntReader
{
public:
	BufferIntReader( Iter begin , Iter end);
	int GetNextInt( int* pDest ); // return 0 - all right, return 1 - end, return -1 - too large number , -2 - invalid symbol
	~BufferIntReader(void);
private:
	char m_pCharArray[10];
	Iter m_begin;
	Iter m_end;
	Iter m_curr;
};

int ReadIntFromString( char* pBuffer );